package com.translate.web.api.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.param.impl.IdPageParam;
import com.translate.vo.TextConfVO;
import com.response.vo.ResponseModel;
import com.controller.base.AbstractCommonController;
import com.translate.web.param.TextConfUpdateParam;
import com.translate.entity.TextConf;
import com.translate.web.service.ITextConfService;
import com.basic.service.contract.IBaseService;

@RestController
@RequestMapping("textConf")
public class TextConfController extends AbstractCommonController<TextConf, IdPageParam> {
	private ITextConfService service;


	public TextConfController(ITextConfService service) {
		this.service = service;
	}

	protected IBaseService<TextConf> getBaseService() {
		return this.service;
	}

	/**
	 * 推荐奖励规则
	 */
	@PostMapping("/recommendedRewardRules")
	public ResponseModel<List<TextConf>> recommendedRewardRules() {
		return ResponseModel.<List<TextConf>>success(this.service.getListByType(1));
	}
	
	/**
	 * 预存奖励规则
	 */
	@PostMapping("/preExistingRewardRules")
	public ResponseModel<List<TextConf>> preExistingRewardRules() {
		return ResponseModel.<List<TextConf>>success(this.service.getListByType(2));
	}
	
	/**
	 * .团队签约规则
	 */
	@PostMapping("/teamSigningRules")
	public ResponseModel<List<TextConf>> teamSigningRules() {
		return ResponseModel.<List<TextConf>>success(this.service.getListByType(3));
	}
	
	/**
	 * 价格方案说明
	 */
	@PostMapping("/priceSchemeDescription")
	public ResponseModel<List<TextConf>> priceSchemeDescription() {
		return ResponseModel.<List<TextConf>>success(this.service.getListByType(5));
	}
	
	
	/**
	 * 加入团队说明
	 */
	@PostMapping("/joinTeamRules")
	public ResponseModel<List<TextConf>> joinTeamRules() {
		return ResponseModel.<List<TextConf>>success(this.service.getListByType(4));
	}


	
	/**
	 * 添加
	 * @param <V>
	 * @param param
	 * @return
	 */
	@PostMapping("/update")
	public ResponseModel<Integer> update(@Validated @RequestBody TextConfUpdateParam param,
			HttpServletRequest httpServletRequest) {
		int res = this.service.parseUpdate(param, TextConf.class);
		return ResponseModel.<Integer>success(res);
	}

	protected <VO> Class<VO> getTarget() {
		return (Class<VO>) TextConfVO.class;
	}
}